package com.sbc.server2.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
public class HelloController {

	//注入http请求客户端
	@Autowired
	RestTemplate restTemplate;
	
    @RequestMapping("/")
    public String index() {
    	//这里没有使用域名或者ip，而是服务的实例名
    	String s1 = restTemplate.getForObject("http://SERVER1/", String.class);
        return "springcloud server2! call " + s1;
    }

}